package com.hjh.pro.exportdb.constant;


import freemarker.template.utility.StringUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Configuration
@PropertySource("classpath:config/export2.properties")
@ConfigurationProperties(prefix="query")
@Component
public class ExportProperties {

    //过滤的字段
    private String filter;
    private List<ExportBean> list;

    public List<ExportBean> getList() {
        return list;
    }

    public void setList(List<ExportBean> list) {
        this.list = list;
    }

    public String getFilter() {
        return filter;
    }

    public void setFilter(String filter) {
        this.filter = filter;
    }

    public List<String> getFilterList() {
        List<String> filterList = new ArrayList();
        String strFilter = StringUtils.trimToEmpty(filter);
        if(StringUtils.isNotBlank(strFilter)){
            String[] itemArr = StringUtils.split(strFilter,",");

            for (String item : itemArr) {
                item = StringUtils.trimToEmpty(item);
                if(StringUtils.isBlank(item)){
                    continue;
                }

                filterList.add(item.toLowerCase());
            }
        }

        return filterList;
    }


}
